<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Lista Afastamentos</title>
        <script type="text/javascript" src="../js/jquery.js" ></script>
        <script type="text/javascript" src="../js/jquery.validate.js"></script>
        <script type="text/javascript" src="../js/jquery.tablescroll.js"></script>
        <script type="text/javascript" src="../js/forms.js"></script>
        <script type="text/javascript" src="../js/jquery-ui-1.8.2.custom.min.js" ></script>
        <link rel="stylesheet" href="../css/ui-lightness/jquery-ui-1.8.2.custom.css">
        <link rel="stylesheet" href="../css/forms.css">
    </head>
    <body>
            <div id="result">
                <form action="fm_new_Afastamentos.jsp">
                    <input type="hidden" name="matricula" value="${param.matricula}">
                    <input type="submit" id="novo_afastamento" value="Incluir"/>
                <input type="hidden" id="token" name="token" value="${sessionScope.token}" /> </form>
                <br>
                <sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
                    SELECT  * FROM Afastamentos
                    inner join tipoafastamento on Afastamentos.id_tipoafastamento=tipoafastamento.id_tipoafastamento
                    left join setores on id_setor_solicitante=setores.id_setor
                    where Afastamentos.matricula=?
                    <sql:param value="${param.matricula}"/>
                </sql:query>
                <table id="tabafastamento" cellspacing="0">
                    <thead>
                        <th>Tipo</th>
                        <th>Atividade extra-classe</th>
                        <th>Início</th>
                        <th>Fim</th>
                        <th>Validado</th>
                        <th>Situação</th>
                        <th>Carga H.</th>
                        <th>Área Sol.</th>
                    </thead>
                    <tbody>
                        <c:forEach var="row" items="${query.rows}">
                            <fmt:formatDate var="data_inicio" value="${row.data_inicio}" pattern="dd/MM/yyyy"/>
                            <fmt:formatDate var="data_fim" value="${row.data_fim}" pattern="dd/MM/yyyy"/>
                            <fmt:formatDate var="data_validado" value="${row.data_validado}" pattern="dd/MM/yyyy"/>
                            <tr>
                                <td><a href="fm_update_Afastamentos.jsp?token=${sessionScope.token}&chave=${row.id_afastamento}">${row.desc_tipoafastamento}</a></td>
                                <td>${row.desc_afastamento}</td>
                                <td>${data_inicio}</td>
                                <td>${data_fim}</td>
                                <td>${data_validado}</td>
                                <td>${row.situacao_afastamento}</td>
                                <td>${row.carga_horaria}</td>
                                <td>${row.desc_setor}</td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
                <script>
                    jQuery(document).ready(function($)
                    {
                        $('#tabafastamento').tableScroll({height:300});

                    });
                </script>
            </div>
    </body>
</html>
